package com.aisino.inveli.vinda.task;

import com.aisino.inveli.vinda.entity.Customer;
import com.aisino.inveli.vinda.service.CustomerService;
import com.aisino.inveli.vinda.utils.TxtUtil;
import javafx.concurrent.Task;

import java.io.File;
import java.util.List;

/**
 * @author leifeng
 * @Date 2017-11-21
 **/
public class CustomerTask extends Task<Boolean> {

    private File file;
    private CustomerService customerService;

    public CustomerTask(File file, CustomerService customerService) {
        this.file = file;
        this.customerService = customerService;
    }

    @Override
    protected Boolean call() throws Exception {
        List<Customer> customerList = TxtUtil.readCusTxt(file);
        Boolean flag = customerService.saveAll(customerList);
        return flag;
    }
}
